/**
 * Created by ChenSanjin on 2021/12/18.
 */


export function getNetworkIp() {
  const os = require('os');
  let needHost = ''; // 打开的host
  try {
      // 获得网络接口列表
      let network = os.networkInterfaces();
      for (let dev in network) {
          let iface = network[dev];
          for (let i = 0; i < iface.length; i++) {
              let alias = iface[i];
              if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
                  needHost = alias.address;
              }
          }
      }
  } catch (e) {
      needHost = 'localhost';
  }
  return needHost;
}
